/** 自动重新加载修改的文件 暂时只支持windows的 
  监控目录清理缓存 子目录只在window下有效linux没用 pm2在window可以正常使用了  */

const fs = require('fs');

module.exports.watch = function(ph){
    console.log(__dirname);
    if(process.platform == "win32"){
        fs.watch("./module/" + ph, {recursive:true}, (eventType, filename)=>{
            const path = require('path');
            LOG.info("watch", eventType, filename);
            if(eventType == 'change'){
                let p = __dirname + path.sep + ph + path.sep + filename;
                if(require.cache[p]){
                    LOG.error("delete cache ", p);
                    delete require.cache[p];
                } 
            }
        })
    }    
}
